﻿//wms服务
function TileWMSService(layerInfo) {
    var TileWMSService = new Object;
    TileWMSService.id = layerInfo.hasOwnProperty("GUID") ? layerInfo.GUID : "";
    TileWMSService.url = layerInfo.hasOwnProperty("URL") ? layerInfo.URL : "";
    TileWMSService.name = layerInfo.hasOwnProperty("NAME") ? layerInfo.NAME : "";
    TileWMSService.servertype = layerInfo.hasOwnProperty("SERVERTYPE") ? layerInfo.SERVERTYPE : "";
    TileWMSService.params = layerInfo.hasOwnProperty("PARAMETERS") ? layerInfo.PARAMETERS : "";
    TileWMSService.prj = layerInfo.hasOwnProperty("PRJ") ? layerInfo.PRJ : "";
    TileWMSService.CreateLayer = function () {
        var id = this.id;
        var url = this.url;
        var name = this.name;
        var prj = this.prj;
        var params = this.params;
        var servertype = this.servertype;
        var m_tilingScheme = prj.indexOf("3857") > -1 ? new Cesium.WebMercatorTilingScheme() : new Cesium.GeographicTilingScheme();
        var layers = viewer.scene.imageryLayers;
        var layerindex = layers._layers.length;
        var thisLayer = layers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
            url: url,
            layers: params,
            tilingScheme: m_tilingScheme,
            parameters: {
                service: "WMS",
                version: "1.1.1",
                request: "GetMap",
                transparent: true,
                format: 'image/png'
            }
        }), layerindex);
        checkLayerTransparent(thisLayer, id, this.alpha);
        return thisLayer;
    }
    return TileWMSService;
}